clc;clear;    
LN1 = 10000;  % 非扩频系统仿真的点数
LN_DS = 1000;  % 扩频系统仿真点数
L=8;  %内插系数
W= 0.25;  %载波系数
EbNo = 0:10; %EbNo
SNR1 = EbNo - 10 * log10(8) + 10*log10(2);     %计算得到非扩频系统SNR
SNR2 = EbNo - 10 * log10(8) + 10*log10(2) - 10*log10(255);  %计算得到扩频系统SNR

for n= 1:11  % 循环运算得到误码率曲线
    a = SNR1(n);
    b= SNR2(n);
    n
    [b2_0_b(n),signal1]= basictral(LN1,L,a);
    [b2_0_a(n),signal2]= basicrcos(LN1,L,a);
    [b2_0_c(n),signal3]= bpskrcos(LN1,L,a,W)
    [b2_0_d(n),signal4]  = DSkuopin(LN_DS, L, b, W);
end
ber =berawgn(EbNo, 'psk' , 2, 'nondiff');
plot(EbNo,ber, 'b-o','LineWidth',1);
hold on;
plot(EbNo,b2_0_b, 'c-v','LineWidth',1); 
plot(EbNo,b2_0_a, 'k-<','LineWidth',1); 
plot (EbNo, b2_0_c, 'r-^','LineWidth',1); 
plot(EbNo,b2_0_d , 'm->','LineWidth',1);
hold off;
% "以MATLAB函数计算理想的误码率"
%  绘制四个系统的误码率曲线